<?php

namespace app\saas\controller;

use app\saas\service\MallService;

/** 后台商城管理 */
class MallController extends BaseController
{
    // 商城列表
    public function getPageList(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(MallService::class, [$this->returnData, $this->params, $this->isSuper]);
        $this->returnData = $service->pageListRun();
        return $this->return_result($this->returnData);
    }

    // 添加
    public function toAdd(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(MallService::class, [$this->returnData, $this->params, $this->isSuper]);
        $this->returnData = $service->toAdd();
        return $this->return_result($this->returnData);
    }

    // 获取信息
    public function getInfo(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(MallService::class, [$this->returnData, $this->params, $this->isSuper]);
        $this->returnData = $service->getInfo();
        return $this->return_result($this->returnData);
    }

    // 更新
    public function toUpdate(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(MallService::class, [$this->returnData, $this->params, $this->isSuper]);
        $this->returnData = $service->toUpdate();
        return $this->return_result($this->returnData);
    }

    // 回收商城
    public function toRecycle(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(MallService::class, [$this->returnData, $this->params, $this->isSuper]);
        $this->returnData = $service->toRecycle();
        return $this->return_result($this->returnData);
    }

    // 删除商城
    public function toDelete(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(MallService::class, [$this->returnData, $this->params, $this->isSuper]);
        $this->returnData = $service->toDelete();
        return $this->return_result($this->returnData);
    }

    // 更新状态
    public function toDisable(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(MallService::class, [$this->returnData, $this->params, $this->isSuper]);
        $this->returnData = $service->toDisable();
        return $this->return_result($this->returnData);
    }

    // 迁移
    public function toMigrate(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(MallService::class, [$this->returnData, $this->params, $this->isSuper]);
        $this->returnData = $service->toMigrate();
        return $this->return_result($this->returnData);
    }
}